package com.breaktian.demoapp.ui.tabviewpager;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class MyFragmentPagerAdapter extends FragmentPagerAdapter {
    public String[] mTitles = new String[]{"ONE", "TWO", "THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"};
    private Fragment[] mFragments = new Fragment[]{new OneFragment(), new TwoFragment(), new ThreeFragment(), new FourFragment(), new FiveFragment(), new SixFragment(), new SevenFragment(), new EightFragment(), new NineFragment()};

    public MyFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setTitle(TabLayout tabLayout){
        for(int i=0;i<mTitles.length;i++){
            tabLayout.getTabAt(i).setText(mTitles[i]);

        }
    }

    @Override
    public Fragment getItem(int position) {
//        Fragment fragment = null;
//        switch (position){
//            case 0:
//                fragment = new TwoFragment();
//                break;
//            case 1:
//                fragment = new ThreeFragment();
//                break;
//            case 2:
//                fragment = new FourFragment();
//                break;
//            case 3:
//                fragment = new FiveFragment();
//                break;
//            case 4:
//                fragment = new SixFragment();
//                break;
//            case 5:
//                fragment = new SevenFragment();
//                break;
//            case 6:
//                fragment = new EightFragment();
//                break;
//            case 7:
//                fragment = new NineFragment();
//                break;
//            default:
//                fragment = new OneFragment();
//                break;
//
//        }
        return mFragments[position];
    }

    @Override
    public int getCount() {
        return mFragments.length;
    }
}
